package com.dormms.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dormms.bean.GoodInfo;
import com.dormms.bean.StaffInfo;
import com.dormms.dto.GoodAdmin;
import com.dormms.dto.GoodAdminInfo;
import com.dormms.service.GoodService;
import com.dormms.tool.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

@Controller
public class GoodInfoController {
	@Autowired
	private GoodService goodService;
	@RequestMapping("super/queryGoodInfoByPageBySuper")
	@ResponseBody
	public PageInfo<GoodInfo> queryGoodInfoByPageBySuper(Page page, GoodInfo goodInfo){
		PageHelper.startPage(page.getCurrPage(), page.getPageSize());
		List<GoodInfo> goodInfos = goodService.queryGoodInfoByGoodInfo(goodInfo);
		PageInfo<GoodInfo> pageInfo = new PageInfo<GoodInfo>(goodInfos);
		return pageInfo;
	}
	
	@RequestMapping("super/insertGoodInfo")
	@ResponseBody
	public Integer insertGoodInfo(GoodInfo goodInfo) {
		return goodService.insertGoodInfo(goodInfo);
	}
	
	@RequestMapping("super/getNoAdminGoodStaff")
	@ResponseBody
	public List<StaffInfo> getNoAdminGoodStaff(){
		return goodService.getNoAdminGoodStaff();
	}
	
	@RequestMapping("super/getAllGoodInfo")
	@ResponseBody
	public List<GoodInfo> getAllGoodInfo(){
		GoodInfo goodInfo = new GoodInfo();
		return goodService.queryGoodInfoByGoodInfo(goodInfo);
	}
	
	@RequestMapping("super/insertGoodAdminInfo")
	@ResponseBody
	public Integer insertGoodAdminInfo(GoodAdmin goodAdmin) {
		return goodService.insertGoodAdminInfo(goodAdmin);
	}
	
	@RequestMapping("super/getGoodAllStaff")
	@ResponseBody
	public GoodAdminInfo getGoodAllStaff(Integer goodInfoId) {
		return goodService.getGoodAllStaff(goodInfoId);
	}
	
	@RequestMapping("super/updateGoodInfoBySuper")
	@ResponseBody
	public Integer updateGoodInfoBySuper(GoodInfo goodInfo) {
		return goodService.updateGoodInfoBySuper(goodInfo);
	}
	
	
	@RequestMapping("super/deleteGoodAdmin")
	@ResponseBody
	public Integer deleteGoodAdmin(String staffId) {
		return goodService.deleteGoodAdmin(staffId);
	}
}
